package cc.vv.btpartyjob.partymanager.delegate

import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.baselibrary.view.LKCircleImageView
import cc.vv.baselibrary.view.webview.BCWebView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.lkimagecomponent2.LKImage
import cc.vv.lkimagecomponent2.lib.mode.ScaleMode
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 社区大党委组织查询托管类
 * Created by Chen.qi on 2018/10/24.
 */
class ZuZhiInfoDetailActivityDelegate : BaseAppDelegate() {


    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_organization_detail
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_aod_topBar)
        titleBar?.setTitle(topBarTitle)
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_aod_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 组织名称
     */
    fun setZuZhiName(name: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_organizationName)
        viewZuZhi?.text = name
    }

    fun setAddress(zuZhiStr: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_organizationAddress)
        viewZuZhi?.text = zuZhiStr
    }

    fun setCode(zuZhiStr: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_organizationCode)
        viewZuZhi?.text = zuZhiStr
    }


    fun setPhone(zuZhiStr: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_organizationTelPhone)
        viewZuZhi?.text = zuZhiStr
    }

    fun setHead(zuZhiStr: String?) {
        val viewZuZhi = getView<LKCircleImageView>(R.id.lkv_aod_principalHead)
        LKImage.load().load(zuZhiStr).placeHolder(R.mipmap.icon_def_image).error(R.mipmap.icon_def_image)
                .scale(ScaleMode.CENTER_CROP).into(viewZuZhi)
    }

    fun fuZeRenName(zuZhiStr: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_principalName)
        viewZuZhi?.text = "负责人：$zuZhiStr"
    }

    fun fuZeRenMobile(zuZhiStr: String?) {
        val viewZuZhi = getView<TextView>(R.id.tv_aod_principalTel)
        viewZuZhi?.text = zuZhiStr
    }


    fun setWebViewContent(webStr: String?) {
        val webView = getView<BCWebView>(R.id.bv_aod_webView)
        webView?.loadData(webStr, "text/html; charset=UTF-8", null)//这种写法可以正确解码
    }

}